<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数字千分位加逗号</title>
</head>

<body>
</body>

<script>
    var string = '1234567890'
    var arr = []
    var finalString

    cutString(string)
    arr.reverse()
    finalString = arr.join(',')
    console.log('finalString', finalString)

    function cutString (string) {
        if (string.length < 4) {
            arr.push(string)
        } else {
            var residualStr = string.substring(0, string.length - 3)
            var cutStr = string.substring(string.length - 3, string.length)
            arr.push(cutStr)
            cutString(residualStr)
        }
    }

</script>

</html>